<template>
	<view class="page">
		<u--form labelWidth='100' :model="userInfo" :rules="rules" ref="Fform">
			<u-form-item label="线索创建时间" borderBottom>
				<u--input v-model="userInfo.clueCreateDateString" disabled disabledColor="#ffffff" border="none">
				</u--input>
			</u-form-item>
			<u-form-item label="出险时间" borderBottom>
				<u--input v-model="userInfo.outRepairDateString" disabled disabledColor="#ffffff" border="none">
				</u--input>
			</u-form-item>
			<u-form-item label="跟踪日期" prop="repairDateString" borderBottom>
				<u--input v-model="userInfo.repairDateString" disabled disabledColor="#ffffff" border="none"></u--input>
				<!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
			</u-form-item>


			<u-form-item label="线索类型" prop="clueType" required borderBottom @click="showClueType = true">

				<u--input v-model="userInfo.clueType" disabled disabledColor="#ffffff" placeholder="请选择线索类型"
					border="none">
				</u--input>
				<u-icon slot="right" name="arrow-down"></u-icon>
			</u-form-item>




			<u-form-item label="车架号" prop="vin" borderBottom>
				<u--input v-model="userInfo.vin" disabledColor="#ffffff" placeholder="请输入车架号码" border="none"></u--input>
				<u-icon slot="right" name="scan" size="24" @click="smTo"></u-icon>
			</u-form-item>
			<u-form-item label="报案人" prop="reportPerson" borderBottom required>
				<u--input v-model="userInfo.reportPerson" border="none"></u--input>
			</u-form-item>

			<u-form-item label="车牌号" prop="carId" borderBottom @click="plateShow = true;" required>
				<u--input v-model="userInfo.carId" disabled disabledColor="#ffffff" placeholder="请填写车牌号" border="none">
				</u--input>
				<u-icon slot="right" name="arrow-down"></u-icon>
			</u-form-item>
			<u-form-item label="电话" prop="phone" borderBottom required>
				<u--input v-model="userInfo.phone" border="none" type='number' maxlength="11"></u--input>
			</u-form-item>

			<u-form-item label="性别" prop="sexName" borderBottom @click="showSex = true">
				<u--input v-model="userInfo.sexName" disabled disabledColor="#ffffff" placeholder="请选择性别" border="none">
				</u--input>
				<u-icon slot="right" name="arrow-down"></u-icon>
			</u-form-item>

			<u-form-item label="品牌名称" prop="carBrandName" required borderBottom @click="insCompanyIdModel(4)">
				<u--input v-model="userInfo.carBrandName" disabled disabledColor="#ffffff" border="none">
				</u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>
			<u-form-item label="车系名称" prop="carClassName" required borderBottom @click="insCompanyIdModel(5)">
				<u--input v-model="userInfo.carClassName" disabled disabledColor="#ffffff" border="none">
				</u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>
			<u-form-item label="车型名称" prop="carTypeName" required borderBottom @click="insCompanyIdModel(6)">
				<u--input v-model="userInfo.carTypeName" disabled disabledColor="#ffffff" border="none">
				</u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>
			<u-form-item label="车型细分名称" prop="carSubtypeName" required borderBottom @click="insCompanyIdModel(7)">
				<u--input v-model="userInfo.carSubtypeName" disabled disabledColor="#ffffff" border="none">
				</u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>
			<u-form-item label="车辆里程" prop="carMileage" borderBottom>
				<u--input v-model="userInfo.carMileage" disabledColor="#ffffff" border="none" type="number">
				</u--input>
			</u-form-item>
			<u-form-item label="人车关系" prop="carRelation" required borderBottom @click="showSex1 = true">
				<u--input v-model="userInfo.carRelation" disabled disabledColor="#ffffff" border="none" type="number">
				</u--input>
				<u-icon slot="right" name="arrow-down"></u-icon>
			</u-form-item>

			<u-form-item label="跟踪详情" prop="remark">
				<u--textarea v-model="userInfo.remark" placeholder="请输入内容"></u--textarea>
			</u-form-item>




			<u-form-item label="图片上传">
				<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
					@oversize="oversize" :maxSize="2*1024*1024" :sizeType="['compressed']" :maxCount="5">
				</u-upload>
			</u-form-item>

			<u-form-item label="当前位置">
				<u--textarea v-model="userInfo.clockInLocation" disabled></u--textarea>
			</u-form-item>



			<u-form-item label="录音上传">
				<u-row justify="space-between">
					<u-col span="8">
						<!-- <button bindtouchstart="handleRecordStart" 
							bindtouchend="handleRecordStop" bindtap='handleRecordClick'>
							<text v-if='timerMsg == 1'> 长按录音</text>
							<text v-if='timerMsg == 2'> 录音中{{Math.round(intervalTime)}}s</text>
							<text v-if='timerMsg == 3'> 播放录音 {{Math.round(intervalTime)}}s</text>
						</button> -->
						<button @click="handleRecordStart" v-if='timerMsg == 1'> 录制
							{{Math.round(intervalTime)}}s</button>
						<button @click="handleRecordStop" v-if='timerMsg == 2'> 结束{{Math.round(intervalTime)}}s</button>
						<button @click="handleRecordClick" v-if='timerMsg == 3'>
							播放{{Math.round(intervalTime)}}s</button>
					</u-col>
					<u-col span="3">
						<u-button type="warning" @click="destruction">
							销毁
						</u-button>
					</u-col>
				</u-row>





			</u-form-item>




		</u--form>



		<u-calendar :show="receiveMsgDateModel" mode="single" @confirm="confirmReceiveMsgDate"
			@close='receiveMsgDateModel=false' closeOnClickOverlay />

		<plate-input v-if="plateShow" :plate="userInfo.carId" @export="setPlate" @close="plateShow = false"
			@transfer="getUser" />

		<u-action-sheet :show="showSex" :actions="actions" title="请选择性别" @close="showSex = false" @select="sexSelect" />
		<u-action-sheet :show="showSex1" :actions="actionsRelationship" title="请选择人车关系" @close="showSex1 = false"
			@select="sexSelect1" />

		<u-action-sheet :show="showClueType" :actions="listClueType" title="请选择线索" @close="showClueType = false"
			@select="clueTypeSelect" />

		<button type='primary' @click="btn">保存</button>

		<u-toast ref="uToast" />

	</view>
</template>

<script>
	import plateInput from '@/common/components/uni-plate-input/uni-plate-input.vue';

	var util = require('@/pagesA/common/utils/count.js') //计算时分秒函数
	import store from '@/store/index.js';

	const recorderManager = uni.getRecorderManager();

	const innerAudioContext = uni.createInnerAudioContext();

	innerAudioContext.autoplay = true;

	import {
		pathToBase64,
		base64ToPath
	} from 'pagesA/common/main/base64.js'
	var lists;
	var lists2;
	var newImgListN = []
	var newImgListN2 = []
	export default {
		components: {
			plateInput,

		},
		data() {
			var phoneRule = (rule, value, callback) => {
				if (this.validatePhone(value)) {
					callback()
				} else {
					callback(new Error('请正确输入手机号码'))
				}
			}
			var vinRule = (rule, value, callback) => {
				if (this.userInfo.vin) {
					if (this.validateVin(value)) {
						// this.$refs.Fform.validateField('vin')
						callback()
					} else {
						callback(new Error('请正确输入车架号'))
					}
				} else {
					callback()
				}

			}

			return {
				showClueType: false,
				voicePath: "",
				positionReq: false,
				timerMsg: 1,
				isRecord: false, // 记录状态,录音中或者是未开始
				recording: false,
				intervalTime: 0,
				intervalTimeTile: 0,
				timer: null,
				timerOut: null,
				receiveMsgDateModel: false, //接收信息时间弹窗
				showSex: false, //性别
				showSex1: false,
				plateShow: false, //车牌号弹框
				fileList1: [],
				fileList2: [],
				userInfo: {
					clueId: '',
					repairDateString: '', //出险时间
					vin: '', //接收信息时间
					reportPerson: '', //报案人
					sex: '', //性别
					sexName: '', //性别页面展示
					carId: '', //车牌号
					isNewEnergy: 7, //是否新能源
					phone: '', //手机号
					remark: '', //备注
					clueType: '', //线索类型
					carBrandName: '',
					carBrand: '',
					carClassName: '',
					carClass: '',
					carTypeName: '',
					carType: '',
					carSubtypeName: '',
					carSubtype: '',
					carMileage: null,
					carRelation: '',
					longitudeAndLatitude: '',
					clockInLocation: ''
				},
				actions: [{
						id: 1,
						name: '男',
					},
					{
						id: 0,
						name: '女',
					}
				],
				listClueType: [{
					id: 1,
					name: "外拓"
				}, {
					id: 2,
					name: "留修且外拓"
				}, {
					id: 0,
					name: "留修"
				}, {
					id: 3,
					name: "客户主动联系"
				}],
				actionsRelationship: [{
						name: '车主关系',
					},
					{
						name: '送修关系',
					}
				],

				rules: {

					// 'carMileage': [{
					// 	type: 'integer',
					// 	required: true,
					// 	message: '车辆里程必须正整数',
					// 	trigger: ['blur', 'change'],
					// }],
					'vin': [{
						validator: vinRule,
						message: "车架号格式不正确",
						trigger: ['change'],
					}, ],
					'carRelation': {
						type: 'string',
						required: true,
						message: '请选择人车关系',
						trigger: ['blur', 'change']
					},
					'reportPerson': {
						type: 'string',
						required: true,
						message: '请填写报案人',
						trigger: ['blur', 'change']
					},
					// 'sexName': {
					// 	type: 'string',
					// 	required: true,
					// 	message: '请选择性别',
					// 	trigger: ['blur', 'change']
					// },
					'carId': {
						type: 'string',
						required: true,
						message: '请填写车牌号',
						trigger: ['blur', 'change']
					},
					'carBrandName': {
						type: 'string',
						required: true,
						message: '请选择品牌名称',
						trigger: ['blur', 'change']
					},
					'carClassName': {
						type: 'string',
						required: true,
						message: '请选择车系名称',
						trigger: ['blur', 'change']
					},
					'carTypeName': {
						type: 'string',
						required: true,
						message: '请选择车型名称',
						trigger: ['blur', 'change']
					},
					'carSubtypeName': {
						type: 'string',
						required: true,
						message: '请选择车型细分名称',
						trigger: ['blur', 'change']
					},



					'phone': [{
							required: true,
							max: 11,
							min: 11,
							message: '请输入手机号',
							trigger: ['change', 'blur'],
						},
						{
							validator: phoneRule,
							message: "手机号格式不正确",
							trigger: ['blur', 'change'],
						},
					]
				},
			}
		},
		onShow() {

		},
		onLoad(option) {
			let self = this;
			self.recordShow()
			uni.showLoading({
				title: '加载中',
				mask: true,
				icon: 'loading',
			});
			recorderManager.onStop(function(res) {
				self.voicePath = res.tempFilePath;
			});

			self.userInfo = {
				...self.userInfo,
				...JSON.parse(option.name)
			}

			// this.userInfo.clueId = option.name
			// console.log(option.name,'1')
			this.userInfo.repairDateString = this.getCurrentDate()




			// if (self.userInfo.clueType == '外拓') {
			// 	self.positionReq = true
			// } else {
			// 	self.positionReq = false
			// }
			if (self.userInfo.carSubtype == '' && self.userInfo.carSubType) {
				self.userInfo.carSubtype = self.userInfo.carSubType
			}
			self.$request('getItemId', {}, 'get').then(res2 => {
				if (res2.code == 200) {
					self.userInfo.itemId = res2.data.itemId
				}
				// uni.hideLoading();
			})


			wx.getLocation({
				type: 'wgs84', // 地图类型写这个
				success(res1) {
					self.userInfo.longitudeAndLatitude = res1.longitude + ',' + res1.latitude


					self.$request('longitudeAndLatitudeToAddress', {
						longitudeAndLatitude: res1.longitude + ',' + res1.latitude
					}, 'get').then(res4 => {
						if (res4.code == 200) {
							self.userInfo.clockInLocation = res4.data
						}
						// uni.hideLoading();
					})


				}
			})


			// wx.authorize({
			// 	scope: 'scope.userFuzzyLocation',
			// 	success(res) {
			// 		console.log(res)
			// 		if (res.errMsg == 'authorize:ok') {

			// 		}
			// 	},
			// 	fail(err) {
			// 		console.log(err)
			// 	}
			// })
			uni.hideLoading();
		},

		onReady() {
			this.$refs.Fform.setRules(this.rules);
		},
		methods: {
			//图片超过大小时取消上传
			oversize(e) {
				this.$u.toast("请传2MB以内大小的图片！");
				return false;
			},
			handleRecordStart() {
				var that = this
				if (that.intervalTime !== 0) {
					that.$refs.uToast.error("请先销毁,在录音!")
					return
				}
				if (that.recording) {
					that.timerMsg = 2
					that.intervalTime = 0
					that.intervalTimeTile = 0
					uni.vibrateLong() //震动
					recorderManager.start({
						format: "mp3",
					});
					that.timer = setInterval(() => {
						uni.$u.toast('正在录音中...')

						that.intervalTime += 0.1
						that.intervalTimeTile += 0.1
					}, 100);
				} else {
					that.$refs.uToast.error("您拒绝了授权,录音功能无法正常使用!")
				}








			},
			handleTouchMove() {
				// this.$refs.uToast.error("录音上划")
				var that = this

				// that.timerMsg = 1
				// that.intervalTime = 0
				// that.voicePath=''

			},
			handleRecordStop() {
				var that = this
				if (that.timerMsg !== 3 && that.intervalTime != 0) {
					that.timerMsg = 3
					// this.$refs.uToast.error("录音结束")
					uni.$u.toast('录音结束')
					uni.hideLoading()
					clearInterval(that.timer);
					recorderManager.stop()
					recorderManager.onStop((res) => {
						that.voicePath = res.tempFilePath
					});

				}
			},
			handleRecordClick() {
				var that = this
				if (that.timerMsg == 3) {
					var timerOut;
					innerAudioContext.src = that.voicePath;
					innerAudioContext.play();
					console.log(that.voicePath)
					console.log(innerAudioContext.src)
					var time = Math.round(that.intervalTimeTile)
					timerOut = setInterval(() => {
						if (Math.round(time) == 0) { //进行判断
							clearInterval(timerOut);
							that.$refs.uToast.success("播放结束")
							that.intervalTime = Math.round(that.intervalTimeTile)
						} else {
							uni.$u.toast('录音播放中...')
							time--;
							that.intervalTime = time
						}
					}, 1000);
				} else {
					this.$refs.uToast.error("录音太短了!!!")
					return
				}
			},

			destruction() {
				var that = this

				that.timerMsg = 1
				that.intervalTime = 0
				that.voicePath = ''
			},







			validateVin: (val) => {
				return /^[A-HJ-NPR-Z\d]{8}[X\d][A-HJ-NPR-Z\d]{3}\d{5}$/.test(val);
			},

			validatePhone: (val) => {
				return /^1[3456789]\d{9}$/.test(val);
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			deletePic2(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},

			imgBase64(url) {
				var that = this
				return new Promise((resolve, reject) => {
					uni.compressImage({
						src: url,
						quality: 40,
						success: res => {
							pathToBase64(res.tempFilePath)
								.then(base64 => {
									resolve(base64)
								})
						}
					})
				})
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.imgBase64(lists[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: lists[i].url,
						urlBase: result
					}))
					fileListLen++
				}
			},
			async afterRead2(event) {

				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				lists2 = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists2.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists2.length; i++) {
					const result = await this.imgBase64(lists2[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: lists2[i].url,
						urlBase: result
					}))
					fileListLen++
				}
			},
			async btn() {
				var that = this
				await that.$refs.Fform.validate().then(res => {
					that.btn2()
				}).catch(errors => {
					uni.$u.toast('校验失败')
				})
			},

			async btn2() {
				var that = this
				// if (that.fileList2.length == 0 && that.userInfo.clueType == '外拓') {
				// 	that.$refs.uToast.error('位置图片必填')
				// 	return
				// }
				uni.showLoading({
					title: '加载中',
					mask: true,
					icon: 'loading',
				});
			var base64img = []
				var base64img2 = []
				/* 图片 */
				if (!uni.$u.test.isEmpty(that.fileList1)) {
					that.fileList1.forEach(obj => {
						base64img.push(obj.urlBase);
					});
				}
				if (!uni.$u.test.isEmpty(that.voicePath)) {
					let upoldeData = await that.upoldeLy()
				}
				// var location = await promise3
				// console.log(newImgListN, 'newImgListNl')
				// console.log(newImgListN2, 'newImgListNl2')
				// console.log(location, 'location')
				
				if(base64img.length != 0){
					that.userInfo.base64img = base64img.toString()
				}else{
					that.userInfo.base64img = ''
				}

				that.userInfo.intervalTime = Math.round(that.intervalTime)
				that.userInfo.userCode = uni.getStorageSync('changeUserList').userCode,
					that.userInfo.companyCode = store.state.userList.companyCode,
					console.log(that.userInfo, '2222')
				// that.userInfo.latitudeAndLongitude = location.longitude + ',' + location.latitude,


				/* 
				 JSON.stringify({
				 	userCode:uni.getStorageSync('changeUserList').userCode,
				 	longitudeAndLatitude: that.userInfo.longitudeAndLatitude,
				 	clueId: that.userInfo.clueId,
				     appEntityVo: that.userInfo,
				 	base64img:JSON.stringify(base64img),
				 	base64img2
				 })
				 */
				that.$request('saveClueHistory',

					that.userInfo


					, 'post', {
						"Content-Type": 'application/json',
						"userCode": uni.getStorageSync('changeUserList').userCode,
						"companyCode": store.state.userList.companyCode
					}).then(r => {
					if (r.code == 200) {

						that.$refs.uToast.success(`${r.message}`)

						let pages = getCurrentPages(); //获取所有页面栈实例列表
						let nowPage = pages[pages.length - 1]; //当前页页面实例
						let prevPage = pages[pages.length - 2]; //上一页页面实例


						setTimeout(function() {
							uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
								delta: 1
							});
						}, 1000)


					} else {
						that.$refs.uToast.error(`${r.message}`)
					}
					uni.hideLoading();
				}).catch(error => {
					// that.$refs.uToast.error(`第${i+1}张上传失败`)
				})
			},
			imgSY() {
				var that = this
				return new Promise((resolve, reject) => {
					for (let i = 0; i < that.fileList1.length; i++) {
						uni.compressImage({
							src: that.fileList1[i].url,
							quality: 50,
							success: res => {
								pathToBase64(res.tempFilePath)
									.then(base64 => {
										resolve(newImgListN.push(base64))
									})
							}
						})
					}

				})
			},
			imgSY2() {
				var that = this
				return new Promise((resolve, reject) => {
					for (let i = 0; i < that.fileList2.length; i++) {
						uni.compressImage({
							src: that.fileList2[i].url,
							quality: 50,
							success: res => {
								pathToBase64(res.tempFilePath)
									.then(base64 => {
										resolve(newImgListN2.push(base64))
									})
							}
						})
					}

				})
			},

			upoldeLy() {
				// 上传录音
				var that = this
				return new Promise((resolve, reject) => {
					wx.uploadFile({
						url: 'https://workapp.sunfonda.com.cn:28149/clue/uniapp/voiceUpload',
						filePath: that.voicePath,
						name: "file", //后台要绑定的名称
						header: {
							"Content-Type": 'application/json',
							"userCode": uni.getStorageSync('changeUserList').userCode,
							"companyCode": store.state.userList.companyCode
						},
						//参数绑定
						formData: {
							"userCode": uni.getStorageSync('changeUserList').userCode,
							"companyCode": store.state.userList.companyCode,
							"clueId": that.userInfo.clueId,
							"itemId": that.userInfo.itemId
						},
						success: function(ress) {
							resolve(ress)
						},
						fail: function(ress) {

						}
					})
				})

			},


			smTo() {
				var that = this
				wx.chooseImage({
					count: 1, // 最多可以选择的图片张数（最大数量-当前已上传数量）
					sizeType: ['compressed'],
					success: function(res) {
						uni.showLoading({
							title: '加载中',
							mask: true
						});
						// 压缩成功回调
						pathToBase64(res.tempFilePaths[0])
							.then(base64 => {
								that.$request('vinToWord', {
									base64img: base64
								}, 'post').then(res => {
									uni.hideLoading();
									if (res.code == 200) {
										that.userInfo.vin = res.data
										that.$refs.uToast.success(`${res.message}`)
										// this.$refs.Fform.validateField('vin')
										return
									} else {
										that.$refs.uToast.error(`${res.message}`)
										return
									}
								})
							})
							.catch(error => {
								console.error(error)
							})
					}

				})





			},
			confirmReceiveMsgDate(E) {
				this.receiveMsgDateModel = false
				this.userInfo.receiveMsgDateString = E[0]
				this.$refs.Fform.validateField('receiveMsgDateString')
			},
			setPlate(plate) {
				if (plate.length >= 7) this.userInfo.carId = plate;
				this.plateShow = false;
				this.$refs.Fform.validateField('carId')
			},

			recordShow(e) {
				var that = this;
				uni.getSetting({
					success(res) {
						// console.log(res.authSetting['scope.record']);
						//判断是否第一次获取录音功能
						if (!res.authSetting['scope.record']) {
							//调用后会立刻弹窗询问用户是否同意授权录音给小程序

							uni.authorize({
								scope: 'scope.record',
								success() {


									that.recording = true;
									// 用户已经同意小程序使用录音功能，后续调用 wx.startRecord 接口不会弹窗询问
									uni.startRecord()
								}
							})
							//判断录音是否是开启状态false没开启就跳转到开启页面
							if (res.authSetting['scope.record'] == false) {

								that.recording = false;
								uni.openSetting({
									success(res) {

										console.log(res.authSetting)
									}
								});
							}
						} else if (res.authSetting['scope.record'] == true) {

							that.recording = true;
						}
					}
				})
			},
			getCurrentDate() {
				var date = new Date();
				var year = date.getFullYear();
				var month = date.getMonth() + 1;
				var day = date.getDate();
				var h = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();

				return year + "-" + this.formatZero(month) + "-" + this.formatZero(day) + " " + h + ":" + minute + ":" + s;
			},
			formatZero(n) {
				if (n >= 0 && n <= 9) {
					return "0" + n;
				} else {
					return n;
				}
			},
			sexSelect(e) {
				this.userInfo.sex = e.id
				this.userInfo.sexName = e.name
				// this.$refs.Fform.validateField('sexName')
			},

			sexSelect1(e) {

				this.userInfo.carRelation = e.name
				this.$refs.Fform.validateField('carRelation')
			},

			insCompanyIdModel(e) {
				if (e == 4) {
					uni.navigateTo({
						url: '/pagesA/index/brandCar?id=' + e
					})
				} else if (e == 5 && this.userInfo.carBrandName != '') {
					uni.navigateTo({
						url: '/pagesA/index/brandCar?id=' + e + '&regionCode=' + this.userInfo.carBrand +
							'&name=' + this.userInfo.carBrandName
					})
				} else if (e == 6 && this.userInfo.carClassName != '') {
					uni.navigateTo({
						url: '/pagesA/index/brandCar?id=' + e + '&regionCode=' + this.userInfo.carClass +
							'&name=' + this.userInfo.carClassName
					})
				} else if (e == 7 && this.userInfo.carTypeName != '') {
					uni.navigateTo({
						url: '/pagesA/index/brandCar?id=' + e + '&regionCode=' + this.userInfo.carType + '&name=' +
							this.userInfo.carTypeName
					})
				}
			},
			clueTypeSelect(e) {
				// this.userInfo.sex = e.id
				this.userInfo.clueType = e.name
				this.$refs.Fform.validateField('clueType')
			},



		},
		watch: {
			// 'userInfo.vin'(newValue, oldValue) {
			// 	if (this.validateVin(newValue)) {
			// 		this.$refs.Fform.validateField('vin')
			// 	}
			// },
			'userInfo.carBrandName'(newValue, oldValue) {
				if (oldValue == '') {
					return
				}
				if (newValue != '' && newValue != oldValue) {
					this.$refs.Fform.validateField('carBrandName')
					this.userInfo.carClassName = ''
					this.userInfo.carTypeName = ''
					this.userInfo.carSubtypeName = ''
				}
			},
			'userInfo.carClassName'(newValue, oldValue) {
				if (oldValue == '') {
					return
				}
				if (newValue != '' && newValue != oldValue) {
					this.$refs.Fform.validateField('carClassName')
					this.userInfo.carTypeName = ''
					this.userInfo.carSubtypeName = ''
				}
			},
			'userInfo.carTypeName'(newValue, oldValue) {
				if (oldValue == '') {
					return
				}
				if (newValue != '' && newValue != oldValue) {
					this.$refs.Fform.validateField('carTypeName')
					this.userInfo.carSubtypeName = ''
				}
			},
			'userInfo.carSubtypeName'(newValue, oldValue) {
				if (newValue != '' && newValue != oldValue) {
					this.$refs.Fform.validateField('carSubtypeName')

				}
			}
		}

	}
</script>

<style>
	.page {
		padding: 10rpx 20rpx;
		box-sizing: border-box;
	}
</style>